$(window).load(function() {
    $('#slider').nivoSlider({
    	effect: 'fade',
    	captionOpacity: 1,
    	directionNav: false
    });
});
function swipeLeft(event)
{
	currentLeft= $('#home-bottom-slider > ul').css('left');
	length = $('#home-bottom-slider > ul > li').length /2
	if(currentLeft =='auto' ||!currentLeft){
		currentLeft = 0;
	}else{
		currentLeft = currentLeft.replace('px', '');
	}
	if(currentLeft > -(length - 6) * 160){
		$('#home-bottom-slider > ul').animate({ left: currentLeft - 160 }, 'slow');
	}
}
function swipeRight(event)
{
	currentLeft= $('#home-bottom-slider > ul').css('left');
	length = $('#home-bottom-slider > ul > li').length /2
	if(currentLeft =='auto' ||!currentLeft){
		currentLeft = 0;
	}else{
		currentLeft = currentLeft.replace('px', '');
	}
	
	if(currentLeft < 0){
		currentLeft = currentLeft.replace('-', '');
		left = 160 - currentLeft;
		$('#home-bottom-slider > ul').animate({ left: left }, 'slow');
	}
	
}

$(document).ready(function() {
	if( navigator.userAgent.match(/Android/i)
	   		 || navigator.userAgent.match(/webOS/i)
	   		 || navigator.userAgent.match(/iPhone/i)
	   		 || navigator.userAgent.match(/iPad/i)
	   		 || navigator.userAgent.match(/iPod/i)
	   		 || navigator.userAgent.match(/BlackBerry/i)
	   		 ){
		var myCarousel = $('#home-bottom-slider').scrollingCarousel({
			scrollSpeed: 'slow',
			looped: false
		});
	   	var swipeOptions=
			{
				swipeLeft:swipeLeft,
				swipeRight:swipeRight,
				threshold:0
			}
	   
	   	$('#home-bottom-slider > ul').swipe( swipeOptions );
	   }else{
		   var myCarousel = $('#home-bottom-slider').scrollingCarousel({
				scrollSpeed: 'slow',
				looped: true
			});
	   }
	$('#main-menu-header').hover(function(){
		$('#main-menu > ul').css('display', 'block');
	});
	$('#main-menu-header').mouseout(function(){
		$('#main-menu > ul').css('display', 'none');
	});
	$('#main-menu > ul').mouseover(function(){
		$('#main-menu > ul').css('display', 'block');
	});
	
	$('#main-menu > ul').mouseleave(function(){
		$('#main-menu > ul').css('display', 'none');
	});
	$('#footter > div').css('display', 'block');
	displayIndex = 0;
	setInterval(function(){
		if(displayIndex < $('#footter div').length - 2){
			displayIndex = displayIndex + 1;
			$('#footter div').css('display', 'none');
			$('#footter div#feed_item_'+displayIndex).show('fast');
		}else{
			displayIndex = 0;
			$('#footter div').css('display', 'none');
			$('#footter div#feed_item_'+displayIndex).show('fast');
		}
	},5000);
	
});